
(function () {
    var btnRead = document.querySelector("#btnRead");
    var more = document.querySelector(".more");
    btnRead.onclick = function () {
        more.style.display = "block";
        this.style.display = "none";
    }
})();

$(function () {
    var index = 0;
    var length = $(".js-loop-item").length;
    var timer;

    $(".js-loop-dot-item").click(function () {
        if($(this).hasClass("on")) {
            return;
        }
        $(this).addClass("on").siblings().removeClass("on");
        index = $(this).index();
        go(index);
    });
    var btnClose = document.querySelector("#sliderClose");
    btnClose.onclick = function () {
        $("#maskShadow").css({
            display: "none"
        });
        $("#maskWrap").css({
            display: "none"
        });
    };

    $(".img").click(function () {
        $("#maskShadow").css({
            display: "block"
        });
        $("#maskWrap").css({
            display: "block"
        });
    });

    function go(index) {
        $(".js-loop-item").eq(index).addClass("selected").siblings().removeClass("selected");
        $(".js-loop-dot-item").eq(index).addClass("on").siblings().removeClass("on");
    }
    function autogo() {
        if(index > length-1) {
            index = 0;
        }
        go(index);
        index++;
        timer =  setTimeout(autogo,3000);
    }
    autogo();
});